Skip to content

Conversation

@ldematte
Copy link
Contributor

@ldematte ldematte commented Feb 4, 2025

While adding some tests to assert that ES handling of multiple headers is in line with the specs (headers are treated in a case-insensitive way - see #116139), we discovered a problem introduced with #95040.
If the header validation fails while we populate the ThreadContext, an error answer is sent, but we also proceed with the normal dispatch. This causes an error downstream: as soon as we try to read the request body, an assertion is hit, as the request has already been closed and marked as completed.
This PR fixes the issue by making the 2 paths mutually exclusive.

@ldematte ldematte added >bug >non-issue :Core/Infra/REST API REST infrastructure and utilities labels Feb 4, 2025
@ldematte ldematte requested review from a team, albertzaharovits and mosche February 4, 2025 15:22
@ldematte ldematte marked this pull request as ready for review February 4, 2025 15:22
@elasticsearchmachine elasticsearchmachine added the Team:Core/Infra Meta label for core/infra team label Feb 4, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

@ldematte ldematte requested a review from DaveCTurner February 4, 2025 17:06
Copy link
Contributor

@DaveCTurner DaveCTurner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Slightly odd tests, kind of unrelated to the bug in question, tho it's not easy to see how else to test for this bug.

@ldematte
Copy link
Contributor Author

ldematte commented Feb 5, 2025

Slightly odd tests, kind of unrelated to the bug in question, tho it's not easy to see how else to test for this bug.

I agree they are kind of unrelated: the case (in)sensitiveness tests came first, just to "prove" (for an unrelated issue) that ES was behaving correctly. They just highlighted the error, as they failed but not where I expected.
Should I separate them in another PR? Wdyt?

Copy link
Contributor

@mosche mosche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks for adding those tests @ldematte 🧸

@ldematte ldematte merged commit a9d6c12 into elastic:main Feb 6, 2025
17 checks passed
@ldematte ldematte deleted the fix/populatePerRequestThreadContext branch February 6, 2025 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>bug :Core/Infra/REST API REST infrastructure and utilities >non-issue Team:Core/Infra Meta label for core/infra team v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants